package akjvm.tools.java.classpath;

import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.AutoCloseInputStream;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

/**
 * Created by VictoryWang on 2016/6/22.
 */
public class DirEntry extends Entry{
    private File dirFile;

    public DirEntry(String path) {
        dirFile = new File(path);
    }

    @Override
    public byte[] readClass(String className) throws IOException {
        return IOUtils.toByteArray(new AutoCloseInputStream(new FileInputStream(new File(dirFile, className))));
    }

    @Override
    public String toString() {
        return dirFile.getAbsolutePath();
    }
}
